<?php
/*========================================= JooSam =========================================/
/																							/
/	Extention:		JooSam																	/
/	Created by:		Broadcastweb.eu - Paules												/
/	Site:			http://www.broadcastweb.eu												/
/	Email:			support@broadcastweb.eu													/
/	Copyright:		2011 - 2012 (c) Broadcastweb.eu											/
/	License:		CC BY-NC-ND 3.0 ~ http://creativecommons.org/licenses/by-nc-nd/3.0/		/
/	File Version:	0003																	/
/																							/
/========================================== JooSam ========================================*/
// Joomla security
defined('_JEXEC') or die;

// Import Joomla Data
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
$sid = JRequest::getVar('sid');
?>

<script>
	Joomla.submitbutton = function(task){if(task == 'samsong.cancel' || document.formvalidator.isValid(document.id('samsong-form'))){Joomla.submitform(task, document.getElementById('samsong-form'));}else{alert("<?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_003'); ?>");}return false;}
</script>
<form action="<?php echo JRoute::_('index.php?option=com_joosam&id='.$sid); ?>" method="post" name="adminForm" id="samsong-form" class="form-validate"><?php
	require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joosam' . DS . 'helpers' . DS . 'helper.samdb.php';
	$server = $this->srvOnEdit;
		$data = SamdbHelper::samdb('getSongInfo', $server['id']);
		$data = $data['data'][0];
		$song_id = $data['ID'];
		$song_filename = $data['filename'];
		$song_diskid = $data['diskID'];
		$song_flags = $data['flags'];
		$song_songtype = $data['songtype'];
		$song_status = $data['status'];
		$song_weight = $data['weight'];
		$song_balance = $data['balance'];
		$song_date_added = $data['date_added'];
		$song_date_played = $data['date_played'];
		$song_date_artist_played = $data['date_artist_played'];
		$song_date_album_played = $data['date_album_played'];
		$song_date_title_played = $data['date_title_played'];
		$song_duration = $data['duration'];
		$song_artist = $data['artist'];
		$song_title = $data['title'];
		$song_album = $data['album'];
		$song_label = $data['label'];
		$song_pline = $data['pline'];
		$song_trackno = $data['trackno'];
		$song_composer = $data['composer'];
		$song_ISRC = $data['ISRC'];
		$song_catalog = $data['catalog'];
		$song_UPC = $data['UPC'];
		$song_feeangency = $data['feeagency'];
		$song_albumyear = $data['albumyear'];
		$song_genre = $data['genre'];
		$song_website = $data['website'];
		$song_buycd = $data['buycd'];
		$song_info = $data['info'];
		$song_lyrics = $data['lyrics'];
		$song_picture = JooSamHelper::getPicture($song_artist, $data['picture'], $server['id']);
		$song_count_played = $data['count_played'];
		$song_count_requested = $data['count_requested'];
		$song_last_requested = $data['last_requested'];
		$song_count_performances = $data['count_performances'];
		$song_xfade = $data['xfade'];
		$song_bpm = $data['bpm'];
		$song_mood = $data['mood'];
		$song_rating = $data['rating'];
		$song_overlay = $data['overlay'];
		$song_playlimit_count = $data['playlimit_count'];
		$song_playlimit_action = $data['playlimit_action'];
		$song_songrights = $data['songrights'];
		$song_adz_listID = $data['adz_listID'];
		$category_id = $data['category_id'];
		$category_name = $data['category_name'];
		if($song_picture['error'] == 'passed'){
			$song_picture = '<img src="'.$song_picture['image'].'" style="margin:0 auto; height:130px; width:130px;"/>';
		}
		else{
			$song_picture = 'Error...: '.$song_picture['image'];
			$song_picture = utf8_encode($song_picture);
		}
		$song_duration = $song_duration/1000;
		$song_duration = round($song_duration);
	?>
	<div class="jsm_editsong_content">
		<h2 class="jsm_editsong_title"><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_004').$server['name']; ?></h2>
		<table class="jsm_editsong_formdata" style="float:left; min-width:500px; min-height:500px;">
			<tr>
				<td>
					<fieldset class="jsm_fieldset">
						<legend><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_005'); ?></legend>
						<table class="adminlist">
							<thead>
								<tr>
									<th width="120"><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_006'); ?></th>
									<th><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_007'); ?></th>
								</tr>
							</thead>
							<tbody>
								<tr class="row0">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_008'); ?></td>
									<td><input style="width:300px;" type="text" name="song_title" id="jsm_input_text_song_title" value="<?php echo utf8_encode($song_title); ?>" /></td>
								</tr>
								<tr class="row1">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_009'); ?></td>
									<td><input style="width:300px;" type="text" name="song_artist" id="jsm_input_text_song_artist" value="<?php echo utf8_encode($song_artist); ?>" /></td>
								</tr>
								<tr class="row0">
									<td>Songtype:</td>
									<td>
										<table id="jsm_stype_table">
											<tr>
												<td><input type="radio" name="song_type" id="jsm_input_text_song_typeS" value="S" /></td>
												<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_010'); ?></td>
											</tr>
											<tr>
												<td><input type="radio" name="song_type" id="jsm_input_text_song_typeI" value="I" /></td>
												<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_011'); ?></td>
											</tr>
											<tr>
												<td><input type="radio" name="song_type" id="jsm_input_text_song_typeP" value="P" /></td>
												<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_012'); ?></td>
											</tr>
											<tr>
												<td><input type="radio" name="song_type" id="jsm_input_text_song_typeJ" value="J" /></td>
												<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_013'); ?></td>
											</tr>
											<tr>
												<td><input type="radio" name="song_type" id="jsm_input_text_song_typeA" value="A" /></td>
												<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_014'); ?></td>
											</tr>
											<tr>
												<td><input type="radio" name="song_type" id="jsm_input_text_song_typeN" value="N" /></td>
												<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_015'); ?></td>
											</tr>
											<tr>
												<td><input type="radio" name="song_type" id="jsm_input_text_song_typeV" value="V" /></td>
												<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_016'); ?></td>
											</tr>
											<tr>
												<td><input type="radio" name="song_type" id="jsm_input_text_song_typeX" value="X" /></td>
												<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_017'); ?></td>
											</tr>
											<tr>
												<td><input type="radio" name="song_type" id="jsm_input_text_song_typeC" value="C" /></td>
												<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_018'); ?></td>
											</tr>
											<tr>
												<td><input type="radio" name="song_type" id="jsm_input_text_song_typeZ" value="?" /></td>
												<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_019'); ?></td>
											</tr>
										</table>
										<script>
											var curr = "<?php echo $song_songtype; ?>";
											if((curr != 'S') && (curr != 'I') && (curr != 'P') && (curr != 'J') && (curr != 'A') && (curr != 'N') && (curr != 'V') && (curr != 'X') && (curr != 'C')){
												curr = 'Z';
											}
											var tid = 'jsm_input_text_song_type'+curr;
											document.getElementById(tid).checked = true;
										</script>
									</td>
								</tr>
								<tr class="row1">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_020'); ?></td>
									<td><input style="width:300px;" type="text" name="song_album" id="jsm_input_text_song_album" value="<?php echo utf8_encode($song_album); ?>" /></td>
								</tr>
								<tr class="row0">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_021'); ?></td>
									<td><input type="text" name="song_trackno" id="jsm_input_text_song_trackno" value="<?php echo utf8_encode($song_trackno); ?>" /></td>
								</tr>
								<tr class="row1">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_022'); ?></td>
									<td>
										<table>
											<tr>
												<td style="margin:0;padding:0;">
													<input style="height:22px;margin:0;padding:0;" type="text" name="song_albumyear" value="<?php echo $song_albumyear; ?>" id="jsm_input_text_song_albumyear" /></td>
												<td style="margin:0;padding:0;">
													<input type="button" class="jsm_Admbutton" value="/\" onclick="this.form.song_albumyear.value++;" style="width:15px;font-size:7px;line-height:10px;height:11px;padding:0;margin:0;" />
													<br />
													<input type="button" class="jsm_Admbutton" value="\/" onclick="this.form.song_albumyear.value--;" style="width:15px;font-size:7px;line-height:10px;height:11px;padding:0;margin:0;" />
												</td>
											</tr>
										</table>
									</td>
								</tr>
								<tr class="row0">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_023'); ?></td>
									<td><input style="width:300px;" type="text" name="song_label" id="jsm_input_text_song_label" value="<?php echo utf8_encode($song_label); ?>" /></td>
								</tr>
								<tr class="row1">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_024'); ?></td>
									<td><input style="width:300px;" type="text" name="song_composer" id="jsm_input_text_song_composer" value="<?php echo utf8_encode($song_composer); ?>" /></td>
								</tr>
								<tr class="row0">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_025'); ?></td>
									<td><input style="width:300px;" type="text" name="song_website" id="jsm_input_text_song_website" value="<?php echo utf8_encode($song_website); ?>" /></td>
								</tr>
								<tr class="row1">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_026'); ?></td>
									<td><input style="width:300px;" type="text" name="song_buycd" id="jsm_input_text_song_buycd" value="<?php echo utf8_encode($song_buycd); ?>" /></td>
								</tr>
								<tr class="row0">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_027'); ?></td>
									<td><input style="width:300px;" type="text" name="song_genre" id="jsm_input_text_song_genre" value="<?php echo utf8_encode($song_genre); ?>" /></td>
								</tr>
								<tr class="row1">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_028'); ?></td>
									<td>
										<select name="song_mood" id="jsm_input_text_song_mood">
											<option value="<?php echo utf8_encode($song_mood); ?>" selected><?php echo utf8_encode($song_mood); ?></option>
											<option value="Classical">Classical</option>
											<option value="Dance">Dance</option>
											<option value="Dinner">Dinner</option>
											<option value="Hard">Hard</option>
											<option value="Metal">Metal</option>
											<option value="Rave">Rave</option>
											<option value="Rock">Rock</option>
											<option value="Romantic">Romantic</option>
											<option value="Slow dance">Slow dance</option>
											<option value="Trance">Trance</option>
										</select>
									</td>
								</tr>
								<tr class="row0">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_029'); ?></td>
									<td>
										<div>
										<input type="text" name="song_weight" readonly="true" size="4" id="jsm_input_text_song_weight" value="<?php echo utf8_encode($song_weight); ?>" />
										</div>
										<style>
											#sl0base{
												margin-left:56px;
												margin-top:4px;
											}
											#sl0base img{
												margin:0;
											}
										</style>
										<script>
											var A_TPL3h = {
												'b_vertical' : false,
												'b_watch': true,
												'n_controlWidth': 200,
												'n_controlHeight': 17,
												'n_sliderWidth': 9,
												'n_sliderHeight': 17,
												'n_pathLeft' : 0,
												'n_pathTop' : 0,
												'n_pathLength' : 192,
												's_imgControl': 'components/com_joosam/extras/script/tigra/img/jsm_weight.gif',
												's_imgSlider': 'components/com_joosam/extras/script/tigra/img/sldr5h_sl.gif',
												'n_zIndex': 1
											}
											var A_INIT3h = {
												's_form' : 0,
												's_name': 'song_weight',
												'n_minValue' : 1,
												'n_maxValue' : 100,
												'n_value' : 50,
												'n_step' : 1
											}

											new slider(A_INIT3h, A_TPL3h);
										</script>
									</td>
								</tr>
								<tr class="row1">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_030'); ?></td>
									<td>
										<div>
										<input type="text" name="song_rating" readonly="true" size="4" id="jsm_input_text_song_rating" value="<?php echo utf8_encode($song_rating); ?>" />
										</div>
										<style>
											#sl1base{
												margin-left:56px;
												margin-top:4px;
											}
											#sl1base img{
												margin:0;
											}
										</style>
										<script>
											var A_TPL4h = {
												'b_vertical' : false,
												'b_watch': true,
												'n_controlWidth': 149,
												'n_controlHeight': 17,
												'n_sliderWidth': 9,
												'n_sliderHeight': 17,
												'n_pathLeft' : 1,
												'n_pathTop' : 0,
												'n_pathLength' : 138,
												's_imgControl': 'components/com_joosam/extras/script/tigra/img/jsm_rating.gif',
												's_imgSlider': 'components/com_joosam/extras/script/tigra/img/sldr5h_sl.gif',
												'n_zIndex': 1
											}
											var A_INIT4h = {
												's_form' : 0,
												's_name': 'song_rating',
												'n_minValue' : 0,
												'n_maxValue' : 9,
												'n_value' : 0,
												'n_step' : 1
											}

											new slider(A_INIT4h, A_TPL4h);
										</script>
									</td>
								</tr>
								<tr class="row0">
									<td style="vertical-align:top; padding-top:10px;"><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_031'); ?></td>
									<td><textarea rows="10" cols="70" name="song_lyrics" id="jsm_input_text_song_lyrics" ><?php echo utf8_encode($song_lyrics); ?></textarea></td>
								</tr>
								<tr class="row1">
									<td style="vertical-align:top; padding-top:10px;"><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_032'); ?></td>
									<td><textarea rows="10" cols="70" name="song_info" id="jsm_input_text_song_info" ><?php echo utf8_encode($song_info); ?></textarea></td>
								</tr>
							</tbody>
						</table>
					</fieldset>
				</td>
				<td class="jsm_editsong_noneditData" style="float:left; width:500px; min-height:500px;">
					<fieldset class="jsm_fieldset">
						<legend><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_033'); ?></legend>
						<table class="adminlist">
							<thead>
								<tr>
									<th width="120"><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_034'); ?></th>
									<th><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_035'); ?></th>
								</tr>
							</thead>
							<tbody>
								<tr class="row0"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_036'); ?></td><td><?php echo $song_id; ?></td></tr>
								<tr class="row1"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_037'); ?></td><td><?php echo utf8_encode($song_filename); ?></td></tr>
								<tr class="row0"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_038'); ?></td><td><?php echo $song_diskid; ?></td></tr>
								<tr class="row1"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_039'); ?></td><td><?php echo $category_id; ?></td></tr>
								<tr class="row0"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_040'); ?></td><td><?php echo utf8_encode($category_name); ?></td></tr>
								<tr class="row1"><td style="vertical-align:top;"><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_041'); ?></td><td><?php echo $song_picture; ?></td></tr>
								<tr class="row0"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_042'); ?></td><td><?php echo date('i:s',$song_duration); ?></td></tr>
								<tr class="row1"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_043'); ?></td><td><?php echo $song_date_added; ?></td></tr>
								<tr class="row0"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_044'); ?></td><td><?php echo $song_date_played; ?></td></tr>
								<tr class="row1"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_045'); ?></td><td><?php echo $song_date_artist_played; ?></td></tr>
								<tr class="row0"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_046'); ?></td><td><?php echo $song_date_title_played; ?></td></tr>
								<tr class="row1"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_047'); ?></td><td><?php echo $song_date_album_played; ?></td></tr>
								<tr class="row0"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_048'); ?></td><td><?php echo $song_last_requested; ?></td></tr>
							</tbody>
						</table>
					</fieldset>
					<fieldset class="jsm_fieldset">
						<legend><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_049'); ?></legend>
						<table class="adminlist">
							<thead>
								<tr>
									<th width="120"><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_050'); ?></th>
									<th><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_051'); ?></th>
									<th><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_052'); ?></th>									
								</tr>
							</thead>
							<tbody>
								<tr class="row0">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_053'); ?></td>
									<td><?php echo $song_count_played; ?></td>
									<td><input type="checkbox" name="song_count_played" value="reset" />
								</tr>
								<tr class="row1">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_054'); ?></td>
									<td><?php echo $song_count_requested; ?></td>
									<td><input type="checkbox" name="song_count_requested" value="reset" />
								</tr>
								<tr class="row0">
									<td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_055'); ?></td>
									<td><?php echo $song_playlimit_count; ?></td>
									<td><input type="checkbox" name="song_playlimit_count" value="reset" />
								</tr>
							</tbody>
						</table>
					</fieldset>
					<fieldset class="jsm_fieldset">
						<legend><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_056'); ?></legend>
						<table class="adminlist">
							<thead>
								<tr>
									<th width="120" colspan="2">
										<?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_057'); ?>
									</th>
								</tr>
							</thead>
							<tbody>
								<tr class="row0"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_058'); ?></td><td><input type="checkbox" name="request_song_id" value="<?php echo $song_id; ?>" /></td></tr>
								<tr class="row1"><td>IP</td><td><input type="text" name="request_song_ip" id="request_song_ip" value="123.123.123.123" /></td></tr>
								<tr class="row0"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_059'); ?></td><td><input type="text" id="request_song_name" name="request_song_name" value="Admin" /></td></tr>
								<tr class="row1"><td><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_060'); ?></td><td><textarea rows="5" cols="50" name="request_song_msg" id="request_song_name" ><?php echo JText::_('COM_JOOSAM_VIEWS_SAMSONG_061'); ?></textarea></td>
							</tbody>
						</table>
					</fieldset>
				</td>
			</tr>
		</table>
	</div>
	<div>
		<input type="hidden" name="song_id" value="<?php echo $song_id; ?>" />
		<input type="hidden" name="server_id" value="<?php echo $server['id']; ?>" />
		<input type="hidden" name="task" value="" />
		<?php echo JHtml::_('form.token'); ?>
	</div>
</form>
<div class="clr"></div>